package com.zhongkai.controller;

import com.zhongkai.app.service.IndentStorageService;
import com.zhongkai.model.utils.ZhongkaiResult;
import com.zhongkai.model3.Chinaset;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 采购入库
 * */
@Controller
public class IndentStorageController {

    @Autowired
    private IndentStorageService indentStorageService;




    /**
     * 采购入库
     *
     * @param id       采购订单id

     */
    @RequestMapping(value = "/indent_storage/put", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult putStorage(@RequestParam(defaultValue = "0") Long id,
                                     HttpServletRequest httpServletRequest
    ) {

        Chinaset chinaset = (Chinaset) httpServletRequest.getAttribute("user");
        ZhongkaiResult result = indentStorageService.putStorage(id,chinaset.getSetName(), chinaset.getUuid());

        return result;
    }



    /**
     * 入库列表
     */
    @RequestMapping(value = "/indent_storage/list", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult listStorage(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer rows
    ) {


        ZhongkaiResult result = indentStorageService.listStorage(page,rows);

        return result;
    }


    //----------------------办公采购入库---------------------------------------------




    /**
     * 采购入库
     *
     * @param id       采购订单id
     */
    @RequestMapping(value = "/indent_storage/put2", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult putStorage2(@RequestParam(defaultValue = "0") Long id,
                                      HttpServletRequest httpServletRequest
    ) {
        Chinaset chinaset = (Chinaset) httpServletRequest.getAttribute("user");

        ZhongkaiResult result = indentStorageService.putStorage2(id, chinaset.getSetName(), chinaset.getUuid());

        return result;
    }



    /**
     * 入库列表
     */
    @RequestMapping(value = "/indent_storage/list2", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult listStorage2(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer rows
    ) {


        ZhongkaiResult result = indentStorageService.listStorage2(page,rows);

        return result;
    }
}
